﻿// -----------------------------------------------------------------------
// <copyright file="DomainCollection.cs" company="JSC Centido">
//  Copyright (c) JSC Centido. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------

namespace Centido.Core.Configuration
{
    using System.Configuration;
    using System.Diagnostics.CodeAnalysis;

    /// <summary>
    ///   Collection of domain parameters in a data access application section
    /// </summary>
    [SuppressMessage("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface")]
    public sealed class DomainCollection : ConfigurationElementCollection
    {
        /// <summary>
        ///   Get configuration collection element by index
        /// </summary>
        /// <param name = "index">Element index</param>
        /// <returns>Element with the specified index</returns>
        public DomainElement this[int index]
        {
            get { return (DomainElement)BaseGet(index); }
        }

        /// <summary>
        ///   Get configuration element key
        /// </summary>
        /// <param name = "element">Configuration element</param>
        /// <returns>Key of the specified configuration element</returns>
        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((DomainElement)element).Name;
        }

        /// <summary>
        ///   Create new configuration element
        /// </summary>
        /// <returns>New configuration element</returns>
        protected override ConfigurationElement CreateNewElement()
        {
            return new DomainElement();
        }
    }
}